package main

import (
	"fmt"
	"sync"
)

func main() {
	var wg sync.WaitGroup
	wg.Add(20)

	ch1, ch2 := make(chan struct{}), make(chan struct{})
	go printA(ch1, ch2, &wg)
	go print1(ch1, ch2, &wg)
	ch1 <- struct{}{}
	wg.Wait()
}

func printA(ch1, ch2 chan struct{}, wg *sync.WaitGroup) {
	for i := 0; i < 10; i++ {
		<-ch1
		fmt.Println("printA is printing: ", "A")
		wg.Done()
		ch2 <- struct{}{}
	}
}

func print1(ch1, ch2 chan struct{}, wg *sync.WaitGroup) {
	for i := 0; i < 10; i++ {
		<-ch2
		fmt.Printf("print1 is printing: %d\n", i)
		wg.Done()
		ch1 <- struct{}{}
	}
}
